from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView

from meiduo_admin.serializers.channelSerializer import GoodCategorySerializer, ChannelGroupSerializer
from goods.models import GoodsChannel, GoodsChannelGroup
from meiduo_admin.utils import PaginatorShow
from meiduo_admin.permissions import *


class GoodChannelView(ModelViewSet):
    queryset = GoodsChannel.objects.all().order_by("id")
    serializer_class = GoodCategorySerializer
    permission_classes = [IsAdminUser]

    pagination_class = PaginatorShow


class ChannelGroupView(ListAPIView):
    queryset = GoodsChannelGroup.objects.all()
    serializer_class = ChannelGroupSerializer
    permission_classes = [IsAdminUser]